home *** CD-ROM | disk | FTP | other *** search
/ Shareware Super Platinum 8 / Shareware Super Platinum 8.iso / mac / PROGTOOL / GWMALLOC.ZIP;1 / GWMALLOC.TAR / gw_malloc / heap.h < prev    next >
Encoding:
C/C++ Source or Header  |  1993-04-08  |  2.5 KB  |  89 lines

  1. /*
  2.  * defines for the system specific memory routines
  3.  *
  4.  * Copyright 1992 by Gray Watson and the Antaire Corporation
  5.  *
  6.  * This file is part of the malloc-debug package.
  7.  *
  8.  * This library is free software; you can redistribute it and/or
  9.  * modify it under the terms of the GNU Library General Public
  10.  * License as published by the Free Software Foundation; either
  11.  * version 2 of the License, or (at your option) any later version.
  12.  *
  13.  * This library is distributed in the hope that it will be useful,
  14.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  16.  * Library General Public License for more details.
  17.  *
  18.  * You should have received a copy of the GNU Library General Public
  19.  * License along with this library (see COPYING-LIB); if not, write to the
  20.  * Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  21.  *
  22.  * The author of the program may be contacted at gray.watson@antaire.com
  23.  *
  24.  * $Id: heap.h,v 1.9 1993/03/26 09:16:41 gray Exp $
  25.  */
  26.  
  27. #ifndef __HEAP_H__
  28. #define __HEAP_H__
  29.  
  30. #include "malloc.h"            /* for LOCAL and bool stuff */
  31.  
  32. /*
  33.  * error code returned by heap allocation routine
  34.  */
  35. #define HEAP_ALLOC_ERROR    ((char *)-1)
  36.  
  37. /*
  38.  * probably machine specific defines used for certain calculations
  39.  */
  40. #if HEAP_GROWS_UP
  41.  
  42. /* test whether pointer P is in the heap space */
  43. #define IS_IN_HEAP(p)        \
  44.   ((char *)(p) >= _heap_base && (char *)(p) < _heap_last)
  45.  
  46. /* turn pointer P into a block index */
  47. #define WHICH_BLOCK(p)        (((p) - _heap_base) / BLOCK_SIZE)
  48.  
  49. /* get a pointer to the memory block number C */
  50. #define BLOCK_POINTER(c)    (_heap_base + (c) * BLOCK_SIZE)
  51.  
  52. /* test whether pointer P is on a block boundary */
  53. #define ON_BLOCK(p)        (((p) - _heap_base) % BLOCK_SIZE == 0)
  54.  
  55. /* calculate the size of heap */
  56. #define HEAP_SIZE        (_heap_last - _heap_base)
  57.  
  58. #endif
  59.  
  60. /*<<<<<<<<<<  The below prototypes are auto-generated by fillproto */
  61.  
  62. IMPORT    char        *_heap_base;  /* base of our heap */
  63.  
  64. IMPORT    char        *_heap_last;  /* end of our heap */
  65.  
  66. /*
  67.  * function to get SIZE memory bytes from the end of the heap
  68.  */
  69. IMPORT    char    *_heap_alloc(unsigned int size);
  70.  
  71. /*
  72.  * return a pointer to the current end of the heap
  73.  */
  74. IMPORT    char    *_heap_end(void);
  75.  
  76. /*
  77.  * initialize heap pointers
  78.  */
  79. IMPORT    void    _heap_startup(void);
  80.  
  81. /*
  82.  * align (by extending) _heap_base to BASE byte boundary
  83.  */
  84. IMPORT    char    *_heap_align_base(int base);
  85.  
  86. /*<<<<<<<<<<   This is end of the auto-generated output from fillproto. */
  87.  
  88. #endif /* ! __HEAP_H__ */
  89.